package com.yh.jucTest;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @ClassName Accumlator2
 * @Description TODO
 * @Author 0715-YuHao
 * @Date 2020/12/15 12:37
 */
public class Accumlator2 implements Runnable {

    private AtomicInteger ai;
    private CountDownLatch count;

    Accumlator2(AtomicInteger ai, CountDownLatch count) {
        this.ai = ai;
        this.count = count;
    }

    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            ai.getAndIncrement();
        }
        count.countDown();
    }
}
